package com.wny.backend;
import java.util.ArrayList;
//Local list storage organizes the information received from events and users organized through the Formatted Display class


public class LocalListStorage {
	private ArrayList<FormattedDisplay> otherUsers;
	private ArrayList<FormattedDisplay> eventsNearMe;
	
	public LocalListStorage()
	{
		
	}
	//sets Users ArrayList
	public void setUserList(char[] listOfUsers)
	{
		otherUsers = parseUserString(String.valueOf(listOfUsers));
	}
	//sets Events ArrayList
	public void setEventList(char[] listOfEvents)
	{
		eventsNearMe = parseEventString(String.valueOf(listOfEvents));
	}
	//returns the ArrayList of users
	public ArrayList<FormattedDisplay> getUserList()
	{
		return otherUsers;
	}
	//returns the ArrayList of events
	public ArrayList<FormattedDisplay> getEventList()
	{
		return eventsNearMe;
	}
	//parses listOfUsers
	private ArrayList<FormattedDisplay> parseUserString(String input)
	{
		String[] stringList = input.split("`");
		String attributeList;
		ArrayList<FormattedDisplay> toReturn = new ArrayList<FormattedDisplay>(stringList.length);
		for(int i = 0; i < stringList.length-1; i++)
		{
			attributeList = stringList[i];
			toReturn.add(new User(attributeList));
		}
		return toReturn;
	}
	//parses list of Events
	private ArrayList<FormattedDisplay> parseEventString(String input)
	{
		String[] stringList = input.split("`");
		String attributeList;
		ArrayList<FormattedDisplay> toReturn = new ArrayList<FormattedDisplay>(stringList.length-1);
		for(int i = 0; i < stringList.length-1; i++)
		{
			attributeList = stringList[i];
			toReturn.add(new Event(attributeList));
		}
		return toReturn;
	}

	//clears the lists
	public void clear() {
		// TODO Auto-generated method stub
		eventsNearMe = new ArrayList<FormattedDisplay>();
		otherUsers = new ArrayList<FormattedDisplay>();
		
	}
}
